#ifndef DIRSEARCH_H
#define DIRSEARCH_H

#include <QObject>
#include <QDir>
#include <QAbstractListModel>
#include <QAbstractTableModel>
#include "classmate.h"
#include <QDateTime>
#include <QThreadPool>

class dirsearch : public QAbstractTableModel
{
    Q_OBJECT
    Q_ENUMS(Roles)

public:
//    enum Roles {
//        checked,
//        name
//    };

    explicit dirsearch();

    virtual QHash<int, QByteArray> roleNames() const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    Q_INVOKABLE bool setProperty(int index, const QVariant &value, QString role);
    Q_INVOKABLE int searchFiles();
    Q_INVOKABLE QList<ClassMate> getData();
    Q_INVOKABLE void checkedAllSame();


    Q_INVOKABLE int exportExcelZh();
    Q_INVOKABLE int exportExcelEn();
    Q_INVOKABLE int exportExcel(int itype);
    Q_INVOKABLE int deleteRecords();

signals:
    void excelFinished();
    void excelIdle();
public slots:

private:
    QList<ClassMate> classMateList_;
    QHash<int, QByteArray> roleNames_;
    QFileInfoList list;
    QThreadPool pool;
    bool firstChecked;
};

#endif // DIRSEARCH_H
